package cn.iocoder.yudao.module.erp.service.supplierfleet;

import cn.iocoder.yudao.module.erp.dal.dataobject.finance.bankstatement.BankStatementDO;
import cn.iocoder.yudao.module.erp.dal.mysql.finance.bankstatement.BankStatementMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import cn.iocoder.yudao.module.erp.controller.admin.supplierfleet.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.supplierfleet.SupplierFleetDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.erp.dal.mysql.supplierfleet.SupplierFleetMapper;

import java.util.ArrayList;
import java.util.List;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;

/**
 * 供应商车队信息 Service 实现类
 *
 * @author 天使管理员
 */
@Service
@Validated
public class SupplierFleetServiceImpl implements SupplierFleetService {

    @Resource
    private SupplierFleetMapper supplierFleetMapper;

    @Resource
    private BankStatementMapper bankStatementMapper;

    @Override
    public Integer createSupplierFleet(SupplierFleetSaveReqVO createReqVO) {
        // 插入
        SupplierFleetDO supplierFleet = BeanUtils.toBean(createReqVO, SupplierFleetDO.class);
        supplierFleetMapper.insert(supplierFleet);
        // 返回
        return supplierFleet.getId();
    }

    @Override
    public void updateSupplierFleet(SupplierFleetSaveReqVO updateReqVO) {
        // 更新
        SupplierFleetDO updateObj = BeanUtils.toBean(updateReqVO, SupplierFleetDO.class);
        supplierFleetMapper.updateById(updateObj);
    }

    @Override
    public void deleteSupplierFleet(Integer id) {
        // 删除
        supplierFleetMapper.deleteById(id);
    }


    @Override
    public SupplierFleetDO getSupplierFleet(Integer id) {
        return supplierFleetMapper.selectById(id);
    }

    @Override
    public PageResult<SupplierFleetDO> getSupplierFleetPage(SupplierFleetPageReqVO pageReqVO) {
        return supplierFleetMapper.selectPage(pageReqVO);
    }

    @Override
    public List<SupplierFleetDO> supplierList(String name,Integer isShow) {
        return supplierFleetMapper.supplierList(name,isShow);
    }

    @Override
    public List<Object> bankFleetList(String name, String fleet) {
        List<BankStatementDO> list=bankStatementMapper.bankList(fleet);
        List<SupplierFleetDO> list1=supplierFleetMapper.fleetList(name,fleet);
        List<Object> mergedList = new ArrayList<>();
        mergedList.addAll(list);
        mergedList.addAll(list1);
        return mergedList;
    }

    @Override
    public List<SupplierFleetDO> fleetList(String name,String fleet) {
        return supplierFleetMapper.fleetList(name,fleet);
    }

    @Override
    public List<SupplierFleetDO> fleetPayList(String name,String fleet) {
        return supplierFleetMapper.fleetPayList(name,fleet);
    }

    @Override
    public List<SupplierFleetDO> totalMoney(String name,String fleet,Integer isShow) {
        return supplierFleetMapper.totalMoney(name,fleet,isShow);
    }
}